<template>
	<view>
		<view class="nav-bar" @click="goBack" v-show="id == 7">
			< 春夏季阅读热榜
		</view>
		<view class="nav-bar" @click="goBack" v-show="id == 8">
			< 春夏季问答热榜
		</view>
		<view class="nav-bar" @click="goBack" v-show="id == 1">
			< 月度阅读热榜
		</view>
		<view class="nav-bar" @click="goBack" v-show="id == 2">
			< 月度问答热榜
		</view>
		<u-gap height="100" bgColor="#fff"></u-gap>
		<view class="rank-list">
			<view class="rank-item" @click="naviTo(r.id, r.category)" v-for="(r, i) in RankDetailsList" :key="r.id">
				<view class="rank-image">
					<view class="image-tag">
						No.{{i + 1}}
					</view>
					<image :src="r.cover" mode="widthFix"></image>
				</view>
				<view class="rank-info">
					<view class="rank-title">
						{{r.title}}
					</view>
					<view class="rank-sub">
						{{r.subtitle}}
					</view>
				</view>
			</view>
		</view>
		<u-gap height="50" bgColor="#fff"></u-gap>
	</view>
</template>

<script>
	import {
		http
	} from '../../untils/http.js'
	
	const url = 'find/rank/'
	
	export default {
		data() {
			return {
				RankDetailsList: [],
				title: '',
				id: 0
			}
		},
		mounted() {
			
		},
		onLoad({
			id
		}) {
			this.getRankDetails(id)
			this.id = id
		},
		created() {
		},
		methods: {
			goBack() {
				// 返回上一级并刷新当前页面
				this.$router.go(-1)
			},
			getRankDetails(id) {
				console.log(id);
				http(url + id).then(res => {
					this.RankDetailsList = res.data
					console.log(this.RankDetailsList);
				})
			},
			naviTo(id, category) {
				if (category == 1) {
					uni.navigateTo({
						url: '../ReadContent/ReadContent?id=' + id
					})
				} else if (category == 3) {
					uni.navigateTo({
						url: '../QuestionContent/QuestionContent?id=' + id
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	* {
		box-sizing: border-box;
	}
	
	.nav-bar {
		position: fixed;
		padding: 10px 10px 0;
		width: 750rpx;
		// height: 80rpx;
		line-height: 80rpx;
		border-bottom: 1px solid #c1c1c1;
		background-color: #fff;
		z-index: 1000;
	}
	
	.rank-item {
		padding: 10px;
		display: flex;
		width: 100%;
		
		.rank-image {
			position: relative;
			flex: 1.5;
			margin-right: 10px;
			overflow: hidden;
			
			.image-tag {
				padding: 1px 4px;
				position: absolute;
				left: 0;
				top: 0;
				z-index: 999;
				font-size: 10px;
				color: #d6d6d6;
				background-color: rgba(255, 152, 35, 0.5);
				border-bottom-right-radius: 7px;
			}
			
			image {
				width: 100%;
				height: 100%;
				border-radius: 8px;
			}
		}
		
		.rank-info {
			flex: 8.5;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			
			.rank-title {
				margin-top: 5px;
				font-size: 14px;
			}
			
			.rank-sub {
				margin-bottom: 10px;
				font-size: 10px;
				color: #c1c1c1;
			}
		}
	}
</style>
